<%@include file="/jsp/init.jspf" %>
<layout:top/>
<h1  class="pagetitle">INVOICE</h1>
<hunk:container>
    <hunk:validator form="invoiceForm">
        <hunk:form action="invoice?action=save" name="invoiceForm">
            <table class="hundred">
                <tr>
                    <td>
                        <table>
                            <tr>
                                <td><label class="heading1">Consignor</label></td>
                            </tr>
                            <tr>
                                <td><hunk:textarea name="invoice.consignor.address" container="NULL" rows="5" cols="40"/></td>
                            </tr>
                        </table>
                    </td>
                    <td>
                        <table>
                            <tr>
                                <td><hunk:text name="invoice.invoiceNo" label="Invoice No"/></td>
                                <td><hunk:calendar name="dateFormatted"  container="NULL"/></td>
                            </tr>                           
                            <tr>
                                <td><hunk:text name="invoice.iecCode" label="IEC CODE"/></td>
                            </tr>
                            <tr>
                                <td><hunk:text name="invoice.orderNo" label="Order no"/></td>
                                <td><hunk:calendar name="orderDateFormatted"  container="NULL"/></td>
                            </tr>
                            <tr>
                                <td>Other References (CS) AD CODE : </td>
                                <td><hunk:text name="invoice.adCode" container="NULL"/></td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td>
                        <table>
                            <tr>
                                <td><label class="heading1">Consignee</label></td>
                            </tr>
                            <tr>
                                <td><hunk:textarea name="invoice.consignee.address" container="NULL" rows="5" cols="40"/></td>
                            </tr>
                        </table>
                    </td>
                    <td>
                        <table class="T50 hundred">
                            <tr>
                                <td colspan="2"class="heading1">Buyers (if other than consignee )</td>
                            </tr>
                            <tr>
                                <td>Country of Origin of Goods</td>
                                <td>Country of final Destination</td>
                            </tr>
                            <tr>
                                <td><hunk:text name="invoice.originCountry" container="NULL"/></td>                             
                                <td><hunk:text name="invoice.destinationCountry" container="NULL"/></td>
                            </tr>                           
                            <tr>
                                <td>Pre - Carriage of Goods</td>
                                <td>Terms of Delivery and Payment</td>
                            </tr>
                            <tr>
                                <td>By : <hunk:text name="invoice.preBy" container="NULL"/></td>
                                <td><hunk:text name="invoice.termsOfDelivery" container="NULL"/></td>
                            </tr>    
                        </table>
                        <table class="T50">
                            <tr>
                                <td>Vessel / Freight No</td>
                                <td><hunk:text name="invoice.vesselNo" container="NULL"/></td>
                            </tr>                          
                            <tr>
                                <td>Port of Discharge</td>
                                <td><hunk:text name="invoice.pod" container="NULL"/></td>
                            </tr>
                            <tr>
                                <td>Place of Reciept by Precarrier</td>
                                <td><hunk:text name="invoice.por" container="NULL"/></td>
                            </tr>
                            <tr>
                                <td>Port of Loading</td>
                                <td><hunk:text name="invoice.pol" container="NULL"/></td>
                            </tr>
                            <tr>
                                <td>Final Destination</td>
                                <td><hunk:text name="invoice.destination" container="NULL"/></td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <c:set var="grandTotal" value="0.0"/>
                        <table class="hundred">
                            <tr>
                                <th>Marks no</th>
                                <th>No of package</th>
                                <th>Description of Goods</th>
                                <th>Qty(PCS)</th>
                                <th>Rate - $</th>
                                <th>Total -$</th>
                                <th>Action</th>
                            </tr>
                            <c:forEach items="${invoiceForm.invoice.charges}" var="charge" varStatus="status" >
                                <tr>
                                    <td>${status.count}</td>
                                    <td><hunk:text name="invoice.charges[${status.count-1}].packages" container="NULL"/></td>
                                    <td><hunk:text name="invoice.charges[${status.count-1}].goodDescription" container="NULL"/></td>
                                    <td><hunk:text name="invoice.charges[${status.count-1}].quantity" container="NULL"/></td>
                                    <td><hunk:text name="invoice.charges[${status.count-1}].amount" container="NULL"/></td>
                                    <td>${charge.totalAmount}</td>
                                    <td><a href="${path}/invoice.do?action=removeCharge&charge_id=${charge.id}">Delete</a></td>
                                    <c:set var="grandTotal" value="${grandTotal + charge.totalAmount}"/>
                                </tr>
                            </c:forEach>
                            <tr>
                                <td><a href="${path}/invoice.do?action=addCharge">Add New Charge</a></td>
                                <td colspan="3">&nbsp;</td>
                                <td>Total Amount</td>
                                <td>${grandTotal}</td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td><hunk:submit label="save"/></td>
                </tr>
            </table>
        </hunk:form>
    </hunk:validator>
</hunk:container>

<layout:bottom/>
